package com.ljq.software_springboot.softwareprogram.mapper;

import com.ljq.software_springboot.softwareprogram.entity.Chatgroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ljq.software_springboot.softwareprogram.entity.UserGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-12-29
 */
@Mapper
public interface ChatgroupMapper extends BaseMapper<Chatgroup> {
    @Select("SELECT cg.id, cg.name, cg.creator_id, cg.create_time " +
            "FROM chatgroup cg " +
            "JOIN chat_member cm ON cg.id = cm.group_id " +
            "WHERE cm.user_id = #{userId}")
    List<Chatgroup> findGroups(@Param("userId") Integer userId);
}
